package com.strongwell.awe.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.strongwell.awe.dao.CmsSiteDao;
import com.strongwell.awe.model.CmsSiteEntity;
import com.strongwell.awe.service.CmsSiteService;



@Service("cmsSiteServiceImpl")
public class CmsSiteServiceImpl implements CmsSiteService {
	@Autowired
	private CmsSiteDao cmsSiteDao;
	
	@Override
	public CmsSiteEntity queryObject(Long id){
		return cmsSiteDao.queryObject(id);
	}
	
	@Override
	public List<CmsSiteEntity> queryList(Map<String, Object> map){
		return cmsSiteDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return cmsSiteDao.queryTotal(map);
	}
	
	@Override
	public int delete(Long id){
		return cmsSiteDao.delete(id);
	}
	
	@Override
	public int deleteBatch(Long[] ids){
		return cmsSiteDao.deleteBatch(ids);
	}

	@Override
	public void save(CmsSiteEntity cmssite){
		Date date=new Date();
		cmssite.setCreateTime(date);
		cmsSiteDao.save(cmssite);
	}

	@Override
	public int update(CmsSiteEntity cmssite){
		Date date=new Date();
		cmssite.setUpdateTime(date);
		return cmsSiteDao.update(cmssite);
	}
	@Override
	public int delById(Long id){
		Date date=new Date();
		CmsSiteEntity cmssite= new CmsSiteEntity();
		cmssite.setId(id);
		cmssite.setDeleteTime(date);
		return cmsSiteDao.update(cmssite);
	}

	public int delPatch(String  cmssitestr){
		String[] strs = cmssitestr.split(",");
		if(strs!=null&&strs.length>0){
			for (String str : strs) {
				delById(Long.parseLong(str));
			}
		}
		return 0;
	}

	public CmsSiteEntity queryName(String name){
		return cmsSiteDao.queryName(name);
	}
}
